import { defineStore } from 'pinia'

export const userStore = defineStore('userStore', {
  state: () => {
    return{
      jwt: '',
      permissionCode:-1,
      clubId:-1
    }
  },
  getters: {
    getJWT: (state) => state.jwt,
    getPermission:(state) => state.permissionCode,
    getClubId:(state) => state.clubId,
  },
  actions: {
    setJWT(newJWT){
      this.jwt = newJWT;
    },
    setPermission(newPermission){
      this.permissionCode = newPermission;
    },
    logout(){
      this.jwt = '';
      this.permissionCode = -1;
    },
    setClubID(newClubId){
      this.clubId = newClubId;
    }
  },
  persist:{
    enabled: true,
  }
})
export default userStore;